﻿//Copyright Notice:  ©2009 Microsoft Corporation.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;

namespace Microsoft.InformationSecurity.CISF.Security.AuthZServices
{
    /// <summary>
    /// Contains the Security Group name related to a role and all the Security Groups found in AD that are
    /// descedants of the Security group.
    /// </summary>
    public class RoleMembersEntry : Entry
    {
        #region Constructor
        /// <summary>
        /// Instantiates the Entry object and adds the name identifier.
        /// </summary>
        /// <param name="name">The name identifier of this Entry object.</param>
        public RoleMembersEntry(string name)
        {
            this.entryName = name;
        }

        /// <summary>
        /// Instantiates the Entry object and adds the name identifier.
        /// </summary>
        /// <param name="name">The name identifier of this Entry object.</param>
        /// <param name="sGProperty">A RelatedSGProperty object.</param>
        /// <param name="noDuplicates">
        /// true - duplicate values will be added. 
        /// false - duplicates will be ignored.
        /// </param>
        public RoleMembersEntry(string name, RelatedSGProperty sGProperty, bool noDuplicates)
        {
            this.entryName = name;
            this.Add(sGProperty, noDuplicates);
            this.LoadProperties();
        }

        #endregion

        #region Methods

        #region LoadProperties
        /// <summary>
        /// Sets the behaviors needed to get user data from AD and chile role data from database
        /// </summary>
        /// <remarks>The AD delegate method populates a PersonData type Property and adds the
        /// property to this Entry.  
        /// </remarks>
        public void LoadProperties()
        {
            //Set the delegate method for retrieving PersonData. (strategy pattern)
            this.GetPropertiesBehavior = new GetPersonDataByRelatedSGAD();
            //Call the delegate method just assigned.
            this.PerformGetProperties(this);
        }

        #endregion

        #endregion

    }
}
